home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / faq / comp / macintos / programm / text0000.txt < prev   
Encoding:
Text File  |  1994-04-11  |  61.3 KB  |  1,622 lines

  1. Archive-name: macintosh/programming-faq 
  2.  
  3. The Public Domain Mac Programming FAQ Answer sheet.
  4. Last update: 931023
  5.  
  6. This sheet was started by and is presently maintained by Jon 
  7. W{tte, whom you may reach as h+@nada.kth.se. If there is 
  8. anything you find errant, missing or in need of an update, 
  9. please send me your submission and I will include it (I can't 
  10. promise correct attributions, but I will try) All FAQ Answer 
  11. submissions sent to me will be considered to be in the public 
  12. domain unless stated otherwise (in which case they will not be 
  13. included in this FAQ sheet) 
  14.  
  15. This sheet is currently archived on nada.kth.se where you can 
  16. reach it using afs as /afs/nada.kth.se/public/ftp/pub/hacks/mac-f
  17. aq/CSMP_PD_FAQ or using anonymous FTP (GIVE YOUR E-MAIL ADDRESS 
  18. AS PASSWORD!) as pub/hacks/mac-faq/CSMP_PD_FAQ 
  19.  
  20. I will try to update this sheet every three weeks or so.
  21.  
  22. This sheet is divided into several parts; each of which covers a 
  23. general area which often gets asked about in the Internet 
  24. newsgroup comp.sys.mac.programmer. Please download a copy of 
  25. this answer sheet and search it before you post to the 'net, to 
  26. help reduce bandwidth. 
  27.  
  28. There is NO or VERY LIMITED error checking in these code 
  29. examples, FOR BREVITY ONLY. You should make sure you ALWAYS 
  30. check ALL return codes, and handle any that you are not prepared 
  31. to deal with appropriately. 
  32.  
  33. The coding style used in the example C code is my own, and 
  34. you'll have to live with it.
  35.  
  36. The groups are (you may search for *<number>* to jump directly 
  37. to a group with its questions and answers) 
  38.  
  39. 0) Development and debugging tools and documentation for the Mac 
  40. 1) Files and the File Manager 
  41. 2) Serial ports 
  42. 3) TCP/IP and sockets 
  43. 4) AppleEvents and the Apple Object Model 
  44. 5) AppleScript
  45. 6) Drawing using QuickDraw 
  46. 7) Drawing NOT using QuickDraw (aka directly to screen) 
  47. 8) Cache issues and other processor differences 
  48. 9) What about pre-emptive multitasking? 
  49. 10) Handles; they are driving me crazy; Memory issues 
  50. 11) _Gestalt and compatibility 
  51. 12) Standalone code and dynamic linking 
  52. 13) Keyboard & Mouse for Games and Screen Savers 
  53. 14) QuickTime 
  54. 15) Windows, Menus, Dialogs
  55. 16) Ice Cream and Frozen Yoghurt 
  56.  
  57. *0* Development and debugging tools for the Macintosh 
  58.  
  59. 0.1) Q: What do I need to start writing Macintosh software? 
  60.  
  61. A: A Mac, a lot of time, and a few hundred $. Although you can 
  62. develop software on a Classic-type machine, it is not to be 
  63. attempted by the weak of heart or stressed of time. If you're 
  64. doing paid work and/or work for a company, a Quadra-class 
  65. machine or Centris 650 or better is almost a must; remember that 
  66. your time costs your employer much more than just your salary. 8 
  67. MB is a minimum to run at all comfortably, and Virtual Memory is 
  68. not suited for development work. Similarly; if you don't have at 
  69. least 20 MB free on your hard disk (40 MB for MPW) you need to 
  70. buy more space. 
  71.  
  72. You need a development system such as Think C, CodeWarrior C++, 
  73. MPW C or Prograph, you need at least some of the New Inside Mac 
  74. books (Toolbox Essentials, Files, Memory come to mind) and a 
  75. good entry-level third-party book may help. 
  76.  
  77. Once you are up to speed on the general layout of the Mac and 
  78. its toolboxes, you should call APDA and order the monthly 
  79. developer mailing, which will give you a CD chock full of 
  80. documentation, utilities and system software once a month. You 
  81. will also, obviously, need a CD player; one of which Apple's own 
  82. CD300 is a very good buy at the time of writing this. If you 
  83. don't have the dough for the monthly mailing ($250/year) you can 
  84. order a _develop_ subscription; this quarterly magazine 
  85. ($30-$50/year) comes with a CD containing all Inside Mac 
  86. documentation.
  87.  
  88. Another tool which many find a must-have is the Think Reference 
  89. version 2.0.1, containing reference material on the most used 
  90. parts of the Mac toolbox with lightning-fast look-up and mostly 
  91. correct usage hints and code snippets. 
  92.  
  93. 0.2) Q: What is the most used Macintosh development language? 
  94.  
  95. A: Out of products on the market, I have no idea; both MPW and 
  96. Think products appear to be used. Lately, CodeWarrior has come 
  97. out of nowhere and grabbed a large share of the market 
  98. visibility because they have the fastest compiler and they 
  99. generate PowerPC code as well as 68K code. Among hobbyists, the 
  100. Think products from Symantec are most popular because of the low 
  101. price, and steep educational discounts, and, of course, the 
  102. easily approachable interface! 
  103.  
  104. The Think C linker only strips dead code on a FILE level basis 
  105. (and this is when you turn on "Smart Linking") The MPW linker 
  106. (of no specified IQ, as someone so eloquently put it :-) strips 
  107. dead code by the function, as does CodeWarrior. That may be part 
  108. of the reason the Think C linker is ten times faster than the 
  109. MPW linker. 
  110.  
  111. In the beginning, the Mac was programmed using Mc68000 assembly 
  112. or Pascal; this was reflected in the Old Inside Mac volumes 
  113. which only gave Pascal-style and assembly-style interfaces to 
  114. the Mac toolbox. These days, Apple tells us to use C or even 
  115. better C++ for developing new applications, as that will speed 
  116. up the transition to PowerPC and also coming cross-platform 
  117. efforts. (Language Systems have a Pascal for PowerPC product 
  118. now, but I don't know about pricing or quality)
  119.  
  120. There are also at least two Fortran compilers, at least three 
  121. SmallTalk implementations (ObjectWorks, SmallTalk/V and 
  122. SmallTalkAgents), a world-class LISP/CLOS implementation 
  123. (Macintosh Common Lisp 2.0) and a Modula/2 implementation. 
  124. Apparently, using Envy/packager, you can strip out unused code 
  125. pretty effectively from Digitalk and PP apps, which are then 
  126. smaller (and of course more memory efficient) than C++ apps. 
  127.  
  128. Metrowerks have a Pascal and a Modula II compiler. They're
  129. building C and C++ for both 68k and coming PPC Macs, and
  130. will also have a PowerPC Pascal.
  131.  
  132. CSI has MacForth, of which I only know the name and someone who 
  133. says it's pretty good.
  134.  
  135. There is another good Common Lisp implementation: Procyon Common 
  136. Lisp. I don't know if it is actively supported, but Procyon CL 
  137. is also available for DOS, OS/2 and Windows (as Allegro CL/PC) 
  138. and actively developed. 
  139.  
  140. 0.3) Q: Where do I find a public domain C compiler for the Mac. 
  141. Is there a GCC for the mac? What about the FSF boycott of Apple 
  142. products? 
  143.  
  144. A: There is no really good solution for a "for-free" C 
  145. development system for the Mac. GCC has been ported, but 
  146. requires the MPW shell and MPW assembler to run; these have to 
  147. be bought from APDA. There is a standalone port of GCC 1.37 on 
  148. nic.switch.ch:software/mac/src/think_c. There was a freely 
  149. available C compiler called Harvest C, which was somewhat 
  150. unstable but usable for smaller programs; it was abandoned by 
  151. the original author Eric W Sink because of a lack of time and 
  152. later taken up by the TopSoft project.
  153.  
  154. The FSF boycott of Apple products means they will not talk to 
  155. you if you ask them for help in doing a Mac port, and they will 
  156. not incorporate your changes into their main code base. However, 
  157. they still allow others to port GNU stuff to the Mac, and it has 
  158. been done with most of the application-like GNU programs (bison, 
  159. flex, perl (not really part of GNU), ...) 
  160.  
  161. gcc-1.37r14 V1.1 standalone is available for ftp at the address below.
  162.  
  163. (A) nic.switch.ch:software/mac/src/think_c/GCC_1.37.1r14.sit.bin
  164. (B) nic.switch.ch:software/mac/src/think_c/GCC_1.37.1r14_src.sit.bin
  165. (C) nic.switch.ch:software/mac/src/think_c/GCC_1.37.1r14_libsrc.sit.bin
  166. (D) nic.switch.ch:software/mac/src/think_c/GCC_1.37.1r14_includes.sit.bin
  167.  
  168. Exhibit (A) will be of interest to users who wish to play with an actual
  169. application. This can not be described as finished, but it is at least
  170. functional. Comments and feedback by e-mail to jrrk@camcon.co.uk are
  171. invited. Exhibit (B) will be of interest to those who like to tinker with
  172. source code and crib ideas for their own programs.
  173. Exhibit (C) will be useful to those who need a library to simplify porting
  174. of code from UNIX or who are otherwise fed up with the incompatabilities of
  175. the standard C library provided with THINK C. It is also needed to build
  176. (B) into a complete application, and also provides the basis of the object
  177. libraries supplied with (A).
  178. Exhibit (D) are the conventional (i.e. non mac toolbox) headers that are
  179. needed to compile the source code and for anyone who would like to write
  180. ANSI-C programs. However the number of hacks needed to gcc to make it
  181. support mac native toolbox applications is likely to make it unreliable as
  182. an ANSI compiler. For this purpose, I have found MacMiNT to be a better
  183. alternative.
  184.  
  185. Highly recommended is to get the toolbox includes for MPW 3.2 and the
  186. 'spinside macintosh' hypercard stack from ftp.apple.com These will give
  187. users an idea of how to go about programming stand-alone Mac applications.
  188.  
  189. 0.4) Q: Are there any other free Mac development platforms? 
  190.  
  191. A: Yerk and Mops. These are object oriented languages based on 
  192. the old product Neon which itself was based on Forth. They are 
  193. available with Manuals at oddjob.uchicago.edu (anonymous FTP). 
  194.  
  195. Plus, there's MacGambit, MacScheme, xlisp, and MacMETH which is 
  196. the actual ETH (read: Nick Wirth's group) Modula 2, all for free 
  197. via FTP.
  198.  
  199. And OpenProlog. And SIOD (Scheme in One Defun) And [mail in more 
  200. if you dare]
  201.  
  202. 0.5) Q: What's the difference between the MPW and Think 
  203. environments? 
  204.  
  205. A: The main difference is that Think is an integrated 
  206. environment, while MPW provides you with a command-line shell 
  207. for your Mac and tools to use in it. MPW also has a slightly 
  208. higher systems demand and a much slower linker. 
  209.  
  210. The good thing about MPW is that you can write scripts and make 
  211. files to do anything you want in the way you want it. Think 
  212. still doesn't have a viable solution to do a build that requires 
  213. more than one link operation, or has more than one destination 
  214. file. 
  215.  
  216. For the MPW environment, there are three source level debuggers; 
  217. SADE, SourceBug and Voodoo Monkey. The latter is an experimental 
  218. debugger with support for threads debugging; the middle is 
  219. bundled with MPW while SADE has to be bought separately (but is 
  220. fully scriptable in its own scripting language) 
  221.  
  222. The Think environments have their own integrated debuggers; the 
  223. Think Pascal one has a lot of useful features while the Think 
  224. C/C++ one is a little more basic (but is gaining in 
  225. functionality with each release) Stepping through source code 
  226. and looking at variables is generally faster and easier in Think 
  227. than the MPW debuggers. 
  228.  
  229. Any commercial Mac developer should have both Think and MPW of 
  230. whatever language they prefer (Pascal, C or C++) 
  231.  
  232. 0.6) Q: What is a good low-level debugger for the Mac? 
  233.  
  234. A: MacsBug is freely available for ftp from ftp.apple.com; log 
  235. in as user anonymous and give your FULL e-mail address as 
  236. password. MacsBug is your basic monitor-type debugger that takes 
  237. a few hundred Ks of memory, and lets you break, step, 
  238. disassemble, look at the stack etc of most anything running on 
  239. your Mac. Since it's free (it's also on the developer CDs) and 
  240. provides most of the functionality you need, this is a popular 
  241. choice. 
  242.  
  243. TMON is another debugger which sports a more mac-like interface; 
  244. it provides windows and uses the mouse. It can take as little or 
  245. much memory as you want by excluding or including certain areas 
  246. of functionality. A nice touch is the 6502 disassembler that you 
  247. can use to de-bug the code the IOP processors run on the Mac 
  248. IIfx and Quadra 900/950. 
  249.  
  250. Jasik Designs have a debugger called The Debugger which can do 
  251. both low- and high-level debugging, with or without source and 
  252. for all types of code, application, code resources, everything. 
  253. This is the debugger of choice for many large developers because 
  254. of its high power and many features not found anywhere else. 
  255. However; newcomers beware! This is the Lamborghini of debuggers; 
  256. if you know how to drive it, it is the fastest way from A to B; 
  257. if you don't, you'll just end up in the ditch. As a lady put it:
  258. "The man wouldn't know a user interface if it bit him in the
  259. rear."
  260.  
  261. 0.7) Q: Are there any visual developments environments for the 
  262. Mac (comparable to Visual C++)?
  263.  
  264. A: There is no Visual C++ as such. However, there is a C++ 
  265. parser/editor called ObjectMaster which provides good browsing 
  266. and editing capabilities if you already have a C++ compiler. 
  267. Think C++ also comes with a browser built-in, and you can draw 
  268. dialogs/windows using plain old ResEdit, even for your custom 
  269. view types. 
  270.  
  271. AppMaker is a GUI builder/code generator.  Granted, it's not as 
  272. nice as VC++, but it's quite a product in any case.
  273.  
  274. Also, Neuron Data has their UI tool called Open Interface, which 
  275. is better than VC++ and creates code portable across 35 
  276. platforms. Unfortunately it's $2500 per developer per platform. 
  277. (There's also two other cross-platform products called XVT and 
  278. Galaxy, the former has gotten flak on UseNet while the latter 
  279. reportedly has decent networking support)
  280.  
  281. There is a fully visual, dynamic, object oriented data-flow-drive
  282.   n programming language for the Mac called Prograph Corporate 
  283. Programming Something-or-other (CPX). It is expensive ($1500) 
  284. but offers a built-in database, easy interfaces to existing data 
  285. bases, very high productivity in implement-test-debug cycling 
  286. and also offers cross-platform capabilities (it comes with a 
  287. class library which, when your code is written using it, works 
  288. under Windows after re-compilation) 
  289.  
  290. There is a crossing between SmallTalk and C++ that is called 
  291. Component Workshop; although it seems large and slowly evolving, 
  292. it does offer some promising features not found in C++ itself. 
  293.  
  294. There is also something called SmallTalkAgents that makes it 
  295. easy to create Mac applications using SmallTalk. If you'd rather 
  296. do Common Lisp, Macintosh Common Lisp offers a Common Lisp 
  297. Object System with support for most Mac interface items; you can 
  298. edit code while it is running and build stand-alone 
  299. applications. 
  300.  
  301. However, all of these tools generate rather larger binaries with 
  302. larger system demands than a program written in C. On the other 
  303. hand; C++ programs require more memory and disk space than 
  304. programs written in assembly. It's a trade-off, and I believe 
  305. this type of tools is the wave of the near future. 
  306.  
  307. 0.8) Q: What class libraries are there for the Mac? 
  308.  
  309. A: Apart from the libraries mentioned above, there are three 
  310. contenders: MacApp, TCL, and OOPC. On the horizon may be 
  311. Bedrock. 
  312.  
  313. MacApp is a heavy-duty class library that has tons of features 
  314. and a steep learning curve; it runs under MPW with Pascal or 
  315. C++, and also under Think Pascal 4.0 A major application written 
  316. in MacApp is PhotoShop. 
  317.  
  318. TCL stands for Think Class Library and comes with Think Pascal, 
  319. C or C++. It is a smaller library that still fills most peoples 
  320. needs; since Think C implements a subset of C++ (the most 
  321. important OO concepts such as virtual functions and inheritance) 
  322. and the TCL is carefully written not to take advantage of any 
  323. C++ features not in Think C, you can use it with Think C. A 
  324. major application written in TCL is Lotus 1-2-3. 
  325.  
  326. OOPC is a newcomer in the field, and uses plain ANSI C. However, 
  327. it mangles the pre-processor to provide you with a system with 
  328. full inheritance, virtual functions, and dynamic re-binding of 
  329. functions for classes or individual objects. Start-up is slow, 
  330. since all "linking" of virtual functions and classes is made at 
  331. run-time, but performance otherwise is good. A Windows version 
  332. is promised for later this year. 
  333.  
  334. 0.9) Q: How should I debug and test my software? 
  335.  
  336. A: Get ahold of, and install, the extensions DoubleTrouble, 
  337. DisposeResource and EvenBetterBusError. They will catch 80% of 
  338. any memory related bugs you may have, including many bugs that 
  339. follow NULL handles or pointers. 
  340.  
  341. A low-level debugger is required, and while you install it, 
  342. install the "leaks" dcmd which will help you catch memory leaks 
  343. in your application. All of these tools are available from 
  344. ftp.apple.com. 
  345.  
  346. *1* Files and the File Manager 
  347.  
  348. 1.1) Q: How do I tell fopen() to open a file the user has 
  349. selected using StandardGetFile? 
  350.  
  351. A: The "standard" ANSI C file functions are less than well 
  352. suited for the Macintosh way of doing things. However, if you 
  353. are doing a port for your own enjoyment and benefit (or maybe 
  354. for in-house work) you can use the following function: (see 
  355. below about converting a wdRefNum into a vRefNum/parID pair) 
  356.  
  357. *code*
  358. FILE *
  359. fopen_mac ( short vRefNum , long parID , char * fileName , char * mode ) {
  360.  
  361. short oldVol ;
  362. short aVol ;
  363. long aDir , aProc ;
  364. FILE * ret = NULL ;
  365.  
  366.     if ( GetVol ( NULL , & oldVol ) ) {
  367.         return NULL ;
  368.     }
  369.     if ( GetWDInfo ( oldVol , & aVol , & aDir , & aProc ) ) {
  370.         return NULL  ;
  371.     }
  372.     if ( HSetVol ( NULL , vRefNum , parID ) ) {
  373.         return NULL ;
  374.     }
  375.     ret = fopen ( fileName , mode ) ;
  376.     if ( HSetVol ( aVol , aDir ) ) {
  377.         /* an error we can't currently handle */
  378.     }
  379.     if ( SetVol ( oldVol ) ) {
  380.         /* an error we can't currently handle */
  381.     }
  382.     return ret ;
  383. }
  384. *end*
  385.  
  386. All of the above is necessary for one reason or another - if you 
  387. are interested, by all means look HSetVol up in Think Reference 
  388. 2.0 or New Inside Mac: Files. 
  389.  
  390. In older versions of MPW; this wouldn't work since the MPW 
  391. libraries used to do a GetVol and explicitly use that value by 
  392. itself. 
  393.  
  394. 1.2) Q: When can I use the HOpen, HCreate etc file calls? Are 
  395. they only System 7 calls? 
  396.  
  397. A: All the HXxx calls that take a vRefNum and parID as well as 
  398. the file name are implemented in glue that works on any system 
  399. that has HFS (meaning 3.2 and up with the HD20 INIT, and all 
  400. systems from System 6 and up) 
  401.  
  402. The glue is available in MPW 3.2 and up, and Think C 5.0 and up. 
  403. This goes for all HXxx calls except HOpenDF; therefore, if you 
  404. are interested in System 6 compatibility, use HOpen instead and 
  405. make sure you don't allow file names beginning with a period. 
  406.  
  407. 1.3) Q: Why do you say wdRefNum sometimes and vRefNum sometimes? 
  408. Why do you say parID sometimes and dirID sometimes? 
  409.  
  410. A: When the Mac first made an appearance in 1984, it identified 
  411. files by using a vRefNum (volume reference number meaning a 
  412. floppy disk or later hard disk) and a name. Once HFS saw the 
  413. light of day, folders within folders became a reality, and you 
  414. needed a dirID as well to point out what folder you really meant 
  415. on the volume. However, older programs that wasn't being 
  416. rewritten still knew nothing about directory IDs, so Apple had 
  417. SFGetFile make up "fake" vRefNums that didn't just specify a 
  418.  
  419. volume, but also a parent folder. These are called wdRefNums 
  420. (for working directory) and were a necessary evil invented in 
  421. 1985. You should not create (or, indeed, use) wdRefNums 
  422. yourself. 
  423.  
  424. There is a system-wide table that maps wdRefNums onto 
  425. vRefNum/parID pairs. There is a limit to the size of this table. 
  426. A dirID and a parID is almost the same thing; you say "parID" 
  427. when you mean the folder something is in, while you say a 
  428. "dirID" when you mean the folder itself. If you for instance 
  429. have a folder called "Foo" with a folder called "Bar" in it, the 
  430. parID for "Bar" would be the dirID for "Foo." 
  431.  
  432. 1.4) Q: How do I convert a wdRefNum as returned by SFGetFile 
  433. into a vRefNum/parID pair to use with the HXxx calls. 
  434.  
  435. A: Use GetWDInfo, which is declared as: 
  436.  
  437. Pascal OSErr GetWDInfo ( short wdRefNum , short * vRefNum , long 
  438. * parID , OSType * procID ) ; 
  439.  
  440. The procID parameter must be non-NULL and point to an OSType 
  441. variable, but the value of that variable can and should be 
  442. ignored. 
  443.  
  444. It is recommended that, as soon as you get your hands on a 
  445. wdRefNum, for instance from SFGetFile, you directly convert it 
  446. into a vRefNum/parID pair and always use the latter to reference 
  447. the folder. 
  448.  
  449. 1.5) Q: How do I select a folder using SFGetFile? 
  450.  
  451. A: This requires a custom dialog with a filter proc. It is too 
  452. complicated to show here, but not totally impossible to 
  453. comprehend. There is sample code on ftp.apple.com, in the 
  454. directory dts/snippets, on how to do this. 
  455.  
  456. 1.6) Q: How do I get the full path of a file referenced by a 
  457. vRefNum, parID and name? 
  458.  
  459. A: You don't. 
  460.  
  461. OK, I cheated you. There is exactly ONE valid reason to get the 
  462. full path of a file (or folder, for that matter) and that is to 
  463. display its location to the user in, say, a settings dialog. To 
  464. actually save the location of the file you should do this: 
  465. (assuming the file is in an FSSpec called theFile - you can use 
  466. FSSpecs in your program even if you don't run under System 7; 
  467. just make your own MyFSMakeFSSpec that fills in the FSSpec 
  468. manually if it's not implemented) 
  469.  
  470. *code*
  471. if ( ! aliasManagerAvailable ) { /* System 6 ? */
  472.     GetVolumeName ( theFile -> vRefNum , vName ) ;
  473.     GetVolumeModDate ( vRefNum , & date ) ;
  474.     Save ( vName , date , parID , fileName ) ;
  475. } else {
  476.     NewAlias ( NULL , theFile , & theAlias ) ;
  477.     Save ( theAlias ) ;
  478.     DisposeHandle ( ( Handle ) theAlias ) ;
  479. }
  480. *end*
  481.  
  482. If you are really concerned about these issues (of course you 
  483. are!) you should save BOTH of these methods when available, and 
  484. load back whatever is there that you can handle; since users may 
  485. be using your application in a mixed System 6/System 7 
  486. environment. 
  487.  
  488. To get back to the file is left as an exercise for the reader. 
  489.  
  490. To open a file using fopen() or the Pascal equivalent, see above 
  491. about using and not using HSetVol. 
  492.  
  493. 1.7) Q: What about actually getting the full path for a file? I 
  494. promise I will only use it to show the location of a file to the 
  495. user! 
  496.  
  497. A: Enter PBGetCatInfo, the Vegimatic of the Mac file system. Any 
  498. Mac hacker of knowledge has taken this system call to his heart. 
  499. What you do is this: 
  500.  
  501. *code*
  502. OSErr
  503. GetFolderParent ( FSSpec * fss , FSSpec * parent ) {
  504.  
  505. CInfoPBRec rec ;
  506. short err ;
  507.  
  508.     * parent = * fss ;
  509.     rec . hFileInfo    . ioNamePtr = parent -> name ;
  510.     rec . hFileInfo    . ioVRefNum = parent -> vRefNum ;
  511.     rec . hFileInfo    . ioDirID = parent -> parID ;
  512.     if ( parent -> name [ 0 ] ) {
  513.         rec . hFileInfo . ioFDirIndex = 0 ;
  514.     } else {
  515.         rec . hFileInfo . ioFDirIndex = -1 ;
  516.     }
  517.     rec . hFileInfo    . ioFVersNum = 0 ;
  518.     err = PBGetCatInfoSync ( & rec ) ;
  519.     if ( ! ( rec . hFileInfo . ioFlAttrib & 0x10 ) ) { /* Not a folder */
  520.         if ( ! err ) {
  521.             err = dirNFErr ;
  522.         }
  523.     } else {
  524.         parent -> parID = rec . dirInfo . ioDrParID ;
  525.         parent -> name [ 0 ] = 0 ;
  526.     }
  527.     return err ;
  528. }
  529.  
  530.  
  531. OSErr
  532. GetFullPathHandle ( FSSpec * fss , Handle * h ) {
  533.  
  534. Handle  tempH = NULL ;
  535. short err ;
  536. FSSpec fs = * fss ;
  537.  
  538.     while ( fs . parID > 1 ) {
  539.         tempH = NULL ;
  540.         PtrToHand ( & fs . name [ 1 ] , & tempH , fs . name [ 0 ] ) ;
  541.         PtrAndHand ( ( void * ) ":" , tempH , 1 ) ;
  542.         HandAndHand ( * h , tempH ) ;
  543.         SetHandleSize ( * h , 0L ) ;
  544.         HandAndHand ( tempH , * h ) ;
  545.         DisposeHandle ( tempH ) ;
  546.         tempH = NULL ; 
  547.         GetFolderParent ( & fs , & sSpec ) ;
  548.         fs = sSpec ;
  549.     }
  550.     GetVolName ( fs    . vRefNum , fs . name ) ;
  551.     PtrToHand ( & fs . name [ 1 ] , & tempH , fs . name [ 0 ] ) ;
  552.     PtrAndHand ( ( void * ) ":" , tempH , 1 ) ;
  553.     HandAndHand ( * h , tempH ) ;
  554.     SetHandleSize ( * h , 0L ) ;
  555.     HandAndHand ( tempH , * h ) ;
  556.     DisposeHandle ( tempH ) ;
  557.     tempH = NULL ;
  558.     if ( ! IsFolder ( fss ) ) {
  559.     SetHandleSize ( * h , GetHandleSize ( * h ) - 1 ) ; // Remove colon }
  560.     return 0 ;
  561. }
  562. *end*
  563.  
  564. 1.8) Q: So how do I get the names of the files in a directory? 
  565.  
  566. A: You use PBGetCatInfo again, but this time you set ioFDirIndex 
  567. to 1 or more (you need to know the dirID and vRefNum of the 
  568.  
  569. folder you're interested in) You then call PBGetCatInfoSync for 
  570. values of ioFDirIndex from 1 and up, until you get an fnfErr. 
  571. Any other err means you are not allowed to get info about THAT 
  572. item, but you may be for the next. Then collect the names in the 
  573. string you made ioNamePtr point to as you go along. Note that 
  574. you need to fill in the ioDirID field for each iteration through 
  575. the loop, and preferrably clear the ioFVersNum as well. 
  576.  
  577. Note that the contents of a directory may very well change while 
  578. you are iterating over it; this is most likely on a file server 
  579. that more than one user uses, or under System 7 where you run 
  580. Personal File Share. 
  581.  
  582. 1.9) Q: How do I find the name of a folder for which I only know 
  583. the dirID and vRefNum? 
  584.  
  585. A: You call (surprise!) PBGetCatInfo! Make ioNamePtr point to an 
  586. empty string (but NOT NULL) of length 63 (like, an Str63) and 
  587. ioFDirIndex negative (-1 is a given winner) - this makes 
  588. PBGetCatInfo return information about the vRefNum/dirID folder 
  589. instead of the file/folder specified by vRefNum, parID and name. 
  590.  
  591. 1.10) Q: How do I make the Finder see a new file that I created? 
  592. Or if I changed the type of it; how do I display a new icon for 
  593. it? 
  594.  
  595. A: You call (surprise!) PBGetCatInfo followed by PBSetCatInfo 
  596. for the FOLDER the file is in. Inbetween, you should set 
  597. ioDrMdDat to the current date&time. Code: 
  598.  
  599. *code*
  600. OSErr
  601. TouchFolder ( short vRefNum , long parID ) {
  602.  
  603. CInfoPBRec rec ;
  604. Str63 name ;
  605. short err ;
  606.  
  607.     rec . hFileInfo . ioNamePtr = name ;
  608.     name [ 0 ] = 0 ;
  609.     rec . hFileInfo . ioVRefNum = vRefNum ;
  610.     rec . hFileInfo . ioDirID = parID ;
  611.     rec . hFileInfo . ioFDirIndex = -1 ;
  612.     rec . hFileInfo . ioFVersNum = 0 ;
  613.     err = PBGetCatInfoSync ( & rec ) ;
  614.     if ( err ) {
  615.         return err ;
  616.     }
  617.     GetDateTime ( & rec . dirInfo . ioDrMdDat ) ;
  618.     rec . hFileInfo . ioVRefNum = vRefNum ;
  619.     rec . hFileInfo . ioDirID = parID ;
  620.     rec . hFileInfo . ioFDirIndex = -1 ;
  621.     rec . hFileInfo . ioFVersNum = 0 ;
  622.     rec . hFileInfo . ioNamePtr [ 0 ] = 0 ;
  623.     err = PBSetCatInfoSync ( & rec ) ;
  624.     return err ;
  625. }
  626. *end*
  627.  
  628. 1.11) Q: Aren't we done with PBGetCatInfo soon? 
  629.  
  630. A: Well, it turns out that you can also find out whether an 
  631. FSSpec is a file or a folder by calling PBGetCatInfo and check 
  632. bit 4 (0x10) of ioFlAttr to see whether it is a folder. You may 
  633. prefer to call ResolveAliasFile for this instead. 
  634.  
  635. You can also check the script of the file's title using 
  636. PBGetCatInfo and check the ioFlFndrXInfo field if you want to 
  637. work with other script systems than the Roman system. 
  638.  
  639. Another common use is to find out how many items are in a 
  640. folder; the modification date of something or the correct 
  641. capitalization of its name (since the Mac file system is case 
  642. independent BUT preserves the case the user uses) 
  643.  
  644. 1.12) Q: How do I set what folder should initially be shown in 
  645. the SFGetFile boxes? 
  646.  
  647. A: You stuff the dirID you want to show into the lo-mem global 
  648. CurDirStore, and the NEGATIVE of the vRefNum you want into the 
  649. lo-mem global SFSaveDisk. 
  650.  
  651. If you are using CustomGetFile and return sfSelectionChanged 
  652. from an "init" message handler, you must remember to clear the 
  653. script code, else the selection will not change. 
  654.  
  655. 1.13) Q: How do I find the folder my application started from? 
  656. How do I find the application file that's running?
  657.  
  658. A: Under System 7, you call GetCurrentProcess, followed by 
  659. GetProcessInformation with a pointer to an existing FSSpec in 
  660. the parameter block. This will give you your file, and, by using 
  661. the vRefNum and parID, the folder the application is in.
  662.  
  663. Beware from writing to your applications resource or data forks; 
  664. the former breaks on CDs/write protected floppies/file 
  665. servers/virus checkers, the latter fails on PowerPC as well as 
  666. in the above cases.
  667.  
  668. *2* Serial ports 
  669.  
  670. 2.1) Q: How do I get at the serial ports? 
  671.  
  672. A: You call OpenDriver for the names "\p.AOut" and "\p.AIn" to 
  673. get at the modem port, and "\p.BOut" and "\p.BIn" for the 
  674. printer port. The function RAMSDOpen was designed for the 
  675. original Mac with 128 kB of memory and 64 kB of ROM, and has 
  676. been extinct for several years. 
  677.  
  678. However, many users use their serial ports for MIDI, LocalTalk, 
  679. graphic tablets, or what have you and have installed an 
  680. additional serial port card to get more ports. What you SHOULD 
  681. do as a good application is to use the Comms Toolbox Resource 
  682. Manager to search for serial resources; this requires that the 
  683. Comms Toolbox is present (true on earlier System 6 with an INIT, 
  684. on later System 6 and System 7 always, as well as on A/UX) and 
  685. that you have initialized the comms resource manager. The exact 
  686. code follows (adapted from Inside Mac Comms Toolbox): 
  687.  
  688. *code*
  689. #include <CommsResources.h>
  690. OSErr
  691. FindPorts ( Handle * portOutNames , Handle * portInNames , Handle * names , Handle * iconHandles ) {
  692.  
  693. OSErr ret = noErr ;
  694. short old = 0 ;
  695. CRMRec theCRMRec , * found ;
  696. CRMSerialRecord * serial ;
  697.  
  698.     * portOutNames = NewHandle ( 0L ) ;
  699.     * portInNames = NewHandle ( 0L ) ;
  700.     * names = NewHandle ( 0L ) ;
  701.     * iconHandles = NewHandle ( 0L ) ;
  702.     while ( ! ret ) {
  703.         theCRMRec . crmDeviceType = crmSerialDevice ;
  704.         theCRMRec . crmDeviceID = old ;
  705.         found = ( CRMRec * ) CRMSearch ( ( QElementPtr ) & theCRMRec ) ;
  706.         if ( found ) {
  707.             serial = ( CRMSerialRecord * ) found -> crmAttributes ;
  708.             old = found -> crmDeviceID ;
  709.             PtrAndHand ( & serial -> outputDriverName , * portOutNames ,
  710.                 sizeof ( serial -> outputDriverName ) ) ;
  711.             PtrAndHand ( & serial -> inputDriverName , * portInNames ,
  712.                 sizeof ( serial -> inputDriverName ) ) ;
  713.             PtrAndHand ( & serial -> name , * names , 
  714.                 sizeof ( serial -> name ) ) ;
  715.             PtrAndHand ( & serial -> deviceIcon , * iconHandles ,
  716.                 sizeof ( serial -> deviceIcon ) ) ;
  717.         } else {
  718.             break ;
  719.         }
  720.     }
  721.     return err ;
  722. }
  723. *end*
  724.  
  725. This will create four handles with the driver names, device 
  726. names and driver icon handles for all of the available serial 
  727. devices. Then let the user choose with a pop-up menu or 
  728. scrolling list, and save the choice in your settings file. 
  729.  
  730. You can use OpenDriver, SetReset, SetHShake, SetSetBuf, 
  731. SerGetBuf and the other Serial Manager functions on these 
  732. drivers. To write to the serial port, use FSWrite for 
  733. synchronous writes that wait until all is written, or PBWrite 
  734. asynchronously for queuing up data that is supposed to go out 
  735. but you don't want to wait for it. At least once each tim 
  736.  
  737. e through your event loop, you should call SerGetBuf on the in 
  738. driver reference number you got from OpenDriver, and call FSRead 
  739. for that many bytes - neither more nor less. 
  740.  
  741. If you are REALLY interested in doing the right thing, you will 
  742. use the Communications Toolbox Connection Manager instead; this 
  743. will give you access to modems, direct lines, and networks of 
  744. various kinds using the same API! Great for stuff like BBSes 
  745. that may be on a network as well etc. The Comms Toolbox also 
  746. priovides modularized terminal emulat 
  747.  
  748. ion and file transfer tools, although the Apple-suplied VT102 
  749. tool is pretty lame, as is the VT102 mode of the VT320 tool. 
  750.  
  751. *3* TCP/IP and sockets 
  752.  
  753. 3.1) Q: Where is a Berkley sockets library for the Mac? 
  754.  
  755. A: There are some problems with that. MacTCP, the Mac Toolbox 
  756. implementation of TCP/IP, doesn't have an API that looks at all 
  757. like Berkley sockets. For instance, there is ONE paramater-block 
  758. call to do a combined listen()/accept()/bind() - sort of. I have 
  759. heard that there may be a socket library available by ftp from 
  760. MIT but haven't seen it myself. 
  761.  
  762. There is also a pretty good C++ TCP implementation called GUSI 
  763. which is easily handled, and it also is callable from C using 
  764. the Berkley socket API. Apart from TCP, it also handles 
  765. "standard" Mac network protocols such as ADSP. The big 
  766. disadvantage is that it is currently only implemented for MPW. 
  767. The ftp site is nic.switch.ch, software/mac/src/mpw_c. 
  768.  
  769. I can also recommend the Communications Toolbox; for the price 
  770. of using an API that is simpler than the Berkley sockets, you 
  771. get the benefit of being able to use any kind of connection (TCP 
  772. tools are available) 
  773.  
  774. Novell and Wollogong offer commercial socket-like libraries. 
  775.  
  776. 3.2) Q: Where do I find MacTCP? 
  777.  
  778. A: You can buy the MacTCP developers kit from APDA. It is also 
  779. available on E T O, and if you want saner headers than those, 
  780. try ftp to seeding.apple.com. 
  781.  
  782. *4* AppleEvents and the AppleEvent Object Model 
  783.  
  784. 4.1) Q: What are AppleEvents? 
  785.  
  786. A: AppleEvents are a level-5 network protocol. If you are not 
  787. familiar with the ISO network stack, this means it's a way of 
  788. structuring sessions between network entities (programs) that is 
  789. not dependent on the underlying protocol (such as PPC or TCP/IP) 
  790. Despite being a network protocol, they can be very useful on 
  791. Macs that are not on a network. In short, they provide 
  792. applications with a comprehensive way to send arbitrary 
  793. structured data to other applications (or themselves) which 
  794. receive the events through their main event loop. 
  795.  
  796. The AppleEvent Object Model is a way of looking at applications 
  797. and the data they contain, and also a level-6 network protocol. 
  798. You _can_ send AppleEvent Object Model data through AppleEvents 
  799. (and the standard AppleEvents defined in the AppleEvent Registry 
  800. use it) but you don't have to - unless you want to talk with 
  801. other applications, of course, then the AEOM is a lingua franca. 
  802. 4.2) Q: What are the four required AppleEvents? 
  803.  
  804. A: There are four events your application really must implement 
  805. if you want to sell it: the kCoreEventClass class, 
  806. kAEOpenApplication, kAEQuitApplication, kAEOpenDocuments and 
  807. kAEPrintDocuments events IDs. When you support these events (or 
  808. any AppleEvents) you will not get startup info through 
  809. GetAppParams() anymore, unless you run under System 6 of course. 
  810. The kAEOpenApplication event will be sent to you when the user 
  811. double-clicks your app and it's not started yet. When receiving 
  812. it, you can put up a new untitled window. 
  813.  
  814. kAEOpenDocuments is sent when the user double-clicks your apps 
  815. documents. Note that if the first AppleEvent you receive is a 
  816. kAEOpenDocuments event, the user started your app by 
  817. double-clicking its documents. 
  818.  
  819. kAEPrintDocuments is sent when the user selects your documents 
  820. and chooses "Print" in the Finder menu. If this is the first 
  821. AppleEvent you receive, you should print the documents and then 
  822. quit the application again; if you received a kAEOpenApplication 
  823. or kAEOpenDocuments event before this, you should just print the 
  824. documents and close them when you're done. 
  825.  
  826. kAEQuitApplication is sent to you when the user chooses 
  827. "Shutdown" or "Restart" from the Apple Menu. You should ask the 
  828. user whether he wants to save any unsaved changed documents, and 
  829. then quit unless the user presses Cancel. 
  830.  
  831. Interestingly enough, you can use these four AppleEvents to send 
  832. even to non-AE-aware applications, and the system will translate 
  833. these events into fake menu selections for you. 
  834.  
  835. A good way of shutting down the Finder is to send it a Quit 
  836. AppleEvent. You should send a Quit AppleEvent to File Sharing 
  837. Extension before you shut down the Finder, though; the FSE is 
  838. found by looking for a process with the creator 'hhgg'. 
  839.  
  840. 4.3) Q: Are there any limits or tradeoffs with AppleEvents? 
  841.  
  842. A: As always, more power means more responsibility. 
  843.  
  844. AppleEvents sent to applications on other Macs require 
  845. authentification the first time they are sent. If the remote Mac 
  846. allows Guests to link to programs, the INIT AutoGuest 2.0 might 
  847. help (or the code solution that comes with it and you can build 
  848. into your application) 
  849.  
  850. In the first version of the AppleEvent manager, there was a 
  851. total 64K limit on the size of data and overhead. This limit has 
  852. been lifted with the version of the AppleEvent manager that 
  853. comes with AppleScript. 
  854.  
  855. AppleEvents require a lot of memory copying and handle resizing 
  856. in their construction; this means that large AppleEvents may be 
  857. slow in construction, especially when compared to a pure PPC 
  858. Toolbox or ADSP/ASDSP link. 
  859.  
  860. You should use your own application signature as event class for 
  861. AppleEvents you make up, in order not to collide with anybody 
  862. else. Other than that, you are free to make your own events for 
  863. your own needs, though supporting the required events and at 
  864. least a subset of the Core event suite will buy you a lot of 
  865. functinality from within AppleScript. Especially important are 
  866. the Get Current Selection and Set Current Selection events 
  867. (which are really Get/Set Data on the contents of the current 
  868. selection of the application) 
  869.  
  870. The signature for your application SHOULD be registered with DTS 
  871. to avoid conflicts; this is done through e-mail to 
  872. DEVSUPPORT@AppleLink.Apple.Com and the form you use is located 
  873. on the developer CDs and found on ftp.apple.com. 
  874.  
  875. *5* AppleScript 
  876.  
  877. 5.1) Q: How does AppleEvents interface with AppleScript? 
  878.  
  879. A: AppleEvents are the meat and potatoes of AppleScript. If you 
  880. support the AppleEvent Object Model from within your 
  881. application, users can control you through AppleScript. 
  882.  
  883. The first thing you should do is get ahold of Inside Mac: 
  884. Interapplication Communication, and a copy of the AppleEvents 
  885. Registry. The former tells you all you ever need to know about 
  886. AppleEvents, while the latter is paramount for implementing the 
  887. right standard events. If everybody use the standard events, 
  888. dynamic data interchange between any applications will become 
  889. sweet reality! 
  890.  
  891. Then there is the 'aete' resource which lets you put names on 
  892. the events you support, so that users can "Open Terminology" on 
  893. your application from within the Apple Script Editor and use the 
  894. proper AppleScript commands in their scripts. The format of an 
  895. aete resource is defined in Inside Macintosh: Interapplication 
  896. Communication. 
  897.  
  898. 5.2) Q: Can I compile and run scripts from within my 
  899. application? 
  900.  
  901. A: Yes, this is very simple. There are toolbox calls for reading 
  902. scripts, compiling scripts, and executing scripts. (OSACompile, 
  903. OSAExecute) These are all documented in Inside Mac: 
  904. Interapplication Communication. 
  905.  
  906. 5.3) Q: Is this a good way of getting a macro language almost 
  907. for free? 
  908.  
  909. A: "Good" is an understatement. Just let users write scripts, 
  910. load them into menu items and go. Total systems integration in 
  911. under a week, including adding support for the AEOM to your 
  912. application. 
  913.  
  914. There is source code for an application called "MenuScipter" on 
  915. the developer CD which shows you how to do an application with 
  916. all of the menus being AppleScript scripts. 
  917.  
  918. *6* Drawing using QuickDraw 
  919.  
  920. 6.1) Q: Why is CopyBits so slow? 
  921.  
  922. A: It is not. It just requires some hand-holding to get good 
  923. results. The main rules are: Make sure the source and 
  924. destination pixMaps are of the same depth. 
  925.  
  926. Make sure the front color is black and the back color is white. 
  927.  
  928. Use srcCopy and don't use a masking region. 
  929.  
  930. Copy to an unclipped window (the frontmost window). 
  931.  
  932. Make sure the ctSeed values of the source pixMap and dest pixMap 
  933. match. 
  934.  
  935. Copying few and large pixMaps is faster than copying many and 
  936. small ones. Icon-sized sprites count as small ones. 
  937.  
  938. Make sure your source bitmap or pixelMap has the same alignment, 
  939. when adjusted for the source and destination rect expressed in 
  940. global screen coordinates. The necessary alignment is 32 bits (4 
  941. bytes), although 128 bit (16 byte) alignment is probably even 
  942. better on 68040 macs and won't hurt on other macs. 
  943.  
  944. Example of global alignment: 
  945.  
  946. Your window is positioned at (42,100) (H,V) 
  947.  
  948. Your destination rectangle is (10,20)-(74,52) 
  949.  
  950. The alignment coefficient of the rectangle in global coordinates 
  951. is (42+10)*bitDepth where bitDepth is one of 1,2,4,8,16 or 32. 
  952.  
  953. Make sure your source pixmap rect has the same coeffecient 
  954. modulo your alignment factor (in bits) For black&white macs, 
  955. this is still true, although bitDepth is fix at 1. Offscreen 
  956. pixMaps can calculate with a "global posistion" of 0,0 and get 
  957. correct results. 
  958.  
  959. 6.2) Q: Why is CopyBits still too slow? 
  960.  
  961. A: Because there is always some overhead involved in calling 
  962. QuickDraw; you have the trap dispatcher, clipping checks, and 
  963. checking whether the CopyBits call is being recorded in a PICT 
  964. handle (if you called OpenPicture) 
  965.  
  966. If you can't live with this, look at *7* below, but PLEASE try 
  967. and make CopyBits work, and retain the CopyBits code in your 
  968. application, so users with special monitors (accellerator cards, 
  969. PowerBook color screens, Radius Pivot screens) can still play 
  970. your game. (non-game applications don't need more speed than 
  971. CopyBits can give at its max. Promise!) 
  972.  
  973. 6.3) Q: What is the fastest way to set one pixel? 
  974.  
  975. A: NOT SetCPixel()! Assuming you have the correct ForeColor() 
  976. set, you can set the pen size to (1,0) and call Line (0,1) 
  977.  
  978. I have heard PaintRect is good for this but requires slightly 
  979. more code.  Using PaintRect eliminates a trap call. 
  980.  
  981. 6.4) Q: Why do pictures I record suddenly draw as empty space or 
  982. not draw at all? 
  983.  
  984. A: When recording pictures, you have to set the clipping area to 
  985. exactly the frame of the picture you are recording. This is 
  986. because it is initally set at -32768,32727 in both directions, 
  987. and offsetting the picture even one pixel when drawing it will 
  988. result in the region wrapping around and becoming empty. 
  989.  
  990. When recording pictures, do this: 
  991.  
  992. *code*
  993. PicHandle h = OpenPicture ( & theRect ) ;
  994. ClipRect ( & theRect ) ;
  995.     /* draw the picture */
  996. ClosePicture ( ) ;
  997. *end*
  998.  
  999. 6.5) Q: Where can I find the format of picture files and 
  1000. resources? 
  1001.  
  1002. A: The format of a picture resource version 1 is defined in a 
  1003. technical note. This format is obsolete. 
  1004.  
  1005. The format of a picture resource version 2 is defined in Old 
  1006. Inside Mac vol V, with addenda in Old Inside Mac vol VI. 
  1007.  
  1008. Some things happen with QuickTime compressed pictures; try the 
  1009. Inside Mac: QuickTime book or wait for Inside Mac: Imaging which 
  1010. is the definite reference on QuickDraw. 
  1011.  
  1012. The format of a picture file is the same as that of a picture 
  1013. resource with 512 added 0 bytes in front. 
  1014.  
  1015. 6.6) Q: GWorlds? 
  1016.  
  1017. A: What about them? They're great. Look them up in Old Inside 
  1018. Mac vol VI. Don't forget to SetGWorld back to what it was before 
  1019. calling WaitNextEvent. 
  1020.  
  1021. 6.7) Q: How do I find the current depth of the screen? 
  1022.  
  1023. A: My question to you is: What screen? Many macs have more than 
  1024. one screen attached. You can use GetDeviceList and walk the 
  1025. devices to find the screen you're looking for (use 
  1026. TestDeviceAttrib to see whether it's a screen) or you can call 
  1027. GetMaxDevice() to find the deepest device your window 
  1028. intersects. 
  1029.  
  1030. Once you have the device handle, finding the depth is just a 
  1031. matter of looking at the dgPMap pixMapHandle, and dereference it 
  1032. to the pmSize field. Done. 
  1033.  
  1034. *7* Drawing directly to screen 
  1035.  
  1036. 7.1) Q: Why is it a bad idea to draw directly to screen? 
  1037.  
  1038. A: Because of several reasons: 
  1039.  
  1040. - You will be incompatible with future display hardware. 
  1041.  
  1042. - You will be incompatible with some present-day display 
  1043. hardware, such as Radius Pivots and PowerBook color screens. 
  1044.  
  1045. - You have to think about a lot of things; testing it all on 
  1046. your own machine is not possible and the chances of crashing are 
  1047. great. 
  1048.  
  1049. - You will be incompatible with future hardware where devices 
  1050. may live in some unaccessible I/O space. 
  1051.  
  1052. 7.2) Q: But I really need to do it. I can't make my animation 
  1053. into a QuickTime movie, and CopyBits is too slow, even when 
  1054. syncing to the screen retrace. 
  1055.  
  1056. A: You have to prepare yourself, and ask these questions: 
  1057.  
  1058. 1) Do I want to support all screens, or just 8-bit devices? 
  1059.  
  1060. 2) Do I have a few weeks of free time to make it work? 
  1061.  
  1062. 3) Do I want to get nasty mail when I break on some hardware and 
  1063. have to rev the application - even if I may not be able to get 
  1064. ahold of the hardware that makes it break? 
  1065.  
  1066. If all you're doing is rendering an image pixel-by-pixel or 
  1067. line-by-line, maybe you can draw directly into an offscreen 
  1068. pixMap/GWorld and then CopyBits the entire GWorld to screen? 
  1069. That will be more compatible, especially if you use the 
  1070. keepLocal flag when creating the GWorld. 
  1071.  
  1072. 7.3) Q: Okay, so how do I get the base address of the screen? 
  1073.  
  1074. A: "The" screen? Which screen? There may be several. The base 
  1075. address may be on an accellerated screen card. There may be more 
  1076. than one screen covering the same desktop area. 
  1077.  
  1078. Due to unfortunate circumstances, there is a bug in 
  1079. GetPixBaseAddr() that causes it to return incorrect results for 
  1080. some versions of System 7. Instead, get the baseAddr directly 
  1081. from the gdPMap handle of the GDHandle for the screen you draw 
  1082. to. This address may need switching to 32bit mode to be valid. 
  1083.  
  1084. 7.4) Q: Quit stalling and give me code! 
  1085.  
  1086. A: Okay, but I'll let you sweat over Inside Mac to figure out 
  1087. what it does. All of it is important; believe me! To make this 
  1088. code run faster, a lot of the things it does can be done once 
  1089. before starting to draw. 
  1090.  
  1091. Make sure that you have a window that covers the area where you 
  1092. are drawing, so other windows will not be overdrawn. Also make 
  1093. sure that you do not do direct-to-screen-drawing while you are 
  1094. in the background. 
  1095.  
  1096. *code*
  1097. /* This is presently untested code */
  1098. /* Value is dependent on what depth the screen has */
  1099. /* This code doesn't work on non-color-quickdraw Macs (i e the MacClassic) */
  1100. /* "where" is in GLOBAL coordinates */
  1101. void
  1102. SetPixel ( Point where , unsigned long value ) {
  1103.  
  1104. Rect r ;
  1105. GDHandle theGD ;
  1106. char * ptr ;
  1107. long rowBytes ;
  1108. short bitsPerPixel ;
  1109. PixMapHandle pmh ;
  1110. Boolean oldMode ;
  1111.  
  1112.     r . left = where . h ;
  1113.     r . top = where    . v ;
  1114.     r . right = r . left + 1 ;
  1115.     r . bottom = r . top + 1 ;
  1116.     theGD = GetMaxDevice ( & r ) ;
  1117.     if ( theGD ) {
  1118.         where . v -= ( * theGD ) -> gdRect . left ;
  1119.         where . h -= ( * theGD ) -> gdRect . top ;
  1120.         pmh = ( * theGD ) -> gdPMap ;
  1121.         rowBytes = ( ( * pmh ) -> rowBytes ) & 0x3fff ;
  1122.         ptr = ( char * ) ( * pmh ) -> baseAddr ;
  1123.         bitsPerPixel = ( * pmh ) -> pixelSize ;
  1124.         oldMode = true32b ;
  1125.         ptr += where . v * rowBytes ;
  1126.         SwapMMUMode ( & oldMode ) ;
  1127.         switch ( bitsPerPixel ) {
  1128.         case 1 :
  1129.             if ( value & 1 ) { 
  1130.                 ptr [ where . h >> 3 ] |= ( 128 >> ( where . h & 7 ) ) ;
  1131.             } else {
  1132.                 ptr [ where . h >> 3 ] &= ~( 128 >> ( where . h & 7 ) ) ;
  1133.             }
  1134.             break ;
  1135.         case 2 :
  1136.             ptr [ where . h >> 2 ] &= ( 192 >> 2 * ( where . h & 3 ) ) ;
  1137.             ptr [ where . h >> 2 ] |= ( value & 3 ) << 2 * ( 3 - ( where . h & 3 ) ) ;
  1138.             break ;
  1139.         case 4 :
  1140.             ptr [ where . h >> 1 ] &= ( where . h & 1 ) ? 0xf : 0xf0 ;
  1141.             ptr [ where . h >> 1 ] |= ( value & 15 ) << 4 * ( 1 - ( where . h & 1 ) ) ;
  1142.             break ;
  1143.         case 8 :
  1144.             ptr [ where . h ] = value ;
  1145.             break ;
  1146.         case 16 :
  1147.             ( ( unsigned short * ) ptr ) [ where . h ] = value ;
  1148.             break ;
  1149.         case 32 :
  1150.             ( ( unsigned long * ) ptr ) [ where . h ] = value ;
  1151.             break ;
  1152.         default :
  1153.             abort ( ) ; /* Should never get here */
  1154.         }
  1155.         SwapMMUMode ( & oldMode ) ;
  1156.     }
  1157. }
  1158. *end*
  1159.  
  1160. *8* Cache issues and other processor differences 
  1161.  
  1162. 8.1) Q: Why does my application work on an SE with accellerator 
  1163. (or a Mac II or Quadra), but not on one without? 
  1164.  
  1165. A: Assuming you're not calling Color QuickDraw (which is not 
  1166. available on accellerated SEs), you most probably have an 
  1167. odd-aligned word access somewhere. 
  1168.  
  1169. The 68000 does not allow words or longwords to be read from odd 
  1170. addresses, while the 68020 and up relaxes this restriction (it 
  1171. still is slower than aligned-word access though) 
  1172.  
  1173. This may or may not crash depending on your compiler: 
  1174.  
  1175. *code*
  1176. struct foo {
  1177.     char c1 ;
  1178.     char c2 ;
  1179.     char c3 ;
  1180.     char c4 ;
  1181.     char c5 ;
  1182. } bar ;
  1183.  
  1184.     long * x = ( long * ) & bar . c2 ;
  1185.     * x = 0x12345678 ; /* X is odd if compiler doesn't pad */
  1186.  
  1187. This WILL crash on an SE/Plus/Classic/PB100:
  1188.  
  1189. char foo [ 10 ] ;
  1190.  
  1191.     long * x = ( long * ) & foo [ 1 ] ;
  1192.     * x = 0x12345678 ;
  1193.  
  1194. *end*
  1195.  
  1196. 8.2) Q: Why does my application work on a IIci but not on a 
  1197. Quadra? 
  1198.  
  1199. A: Two reasons: 
  1200.  
  1201. 1) The Quadras 900 and 950 have special processors that handle 
  1202. the serial ports; if you write directly to the serial chips, you 
  1203. will crash (this goes for the IIfx as well) 
  1204.  
  1205. 2) The Quadras have 68040 processors, as have the Centrises. 
  1206. These processors have separate instruction and data caches (like 
  1207. the 68030) but they are larger (4K each) and unlike the 68030 
  1208. which is write-through data cached, the 68040 is copy-back data 
  1209. cached. This means that changes you make to "your code" aren't 
  1210. really changed all the time, since the changes may still be in 
  1211. the data cache and not written to memory when the CPU reads that 
  1212. part of memory into its I-cache. Even worse; that part might 
  1213. already have been read into the I-cache before you change it in 
  1214. the D-cache, meaning that writing out the D-cache will still not 
  1215. be enough. You need to flush both the caches when writing 
  1216. self-modifying code. 
  1217.  
  1218. Self-modifying code includes code that builds its own jump 
  1219. tables and code that decrypts itself and code that "stubs" MDEFs 
  1220. or WDEFs to jump back into the application code. 
  1221.  
  1222. You flush the cache using FlushDataCache() which is implemented 
  1223. if Gestalt says you have a 68020 or better processor (or if the 
  1224. _HwDispatch trap is implemented) 
  1225.  
  1226. 8.3) Q: Why does my application work on my Quadra but not on my 
  1227. accellerated SE? 
  1228.  
  1229. A: You're probably calling Color QuickDraw without first 
  1230. checking if it's available. The following machines do not have 
  1231. color QuickDraw in ROM nor RAM: 
  1232.  
  1233. Mac Plus, Mac SE, Mac Classic, Mac Luggable, PowerBook 100, 
  1234. Outbound 
  1235.  
  1236. 8.4) Q: I do check for color quickdraw, but crash nevertheless. 
  1237.  
  1238. A: _Gestalt lies under some versions of System 7; it says that 
  1239. non-color machines HAVE color QuickDraw when you test using the 
  1240. gestaltQuickdrawFeatures selector. 
  1241.  
  1242. Instead, check the gestaltQuickdrawVersion selector, if it 
  1243. returns >= gestalt8BitQuickdraw then you can safely use 
  1244. gestaltQuickdrawFeatures, else you only have b/w QuickDraw. 
  1245.  
  1246. 8.5) Q: Why are there no C/C++ compilers that optimize for the 
  1247. Mc68040? 
  1248.  
  1249. A: Beats me; optimizing for the 68040 can make programs up to 
  1250. 50% faster on that chip while still losing nothing, or very 
  1251. little (less than 10%) on older chips. 
  1252.  
  1253. *9* Inflammatory subjects 
  1254.  
  1255. 9.1) Q: What about pre-emptive multitasking? 
  1256.  
  1257. A: To the user, the Mac multitasking method, which builds upon 
  1258. each application calling WaitNextEvent, GetNextEvent or 
  1259. EventAvail every so often and the Process Manager/MultiFinder 
  1260. switching applications only at such calls, is at least as good 
  1261. as preemtive multitasking, because the present system 
  1262. priotitizes user interface responsiveness over everything else. 
  1263. The only shortfall about this is formatting floppies, which 
  1264. locks up the Mac CPU. This is because the Mac floppy controller 
  1265. is really stupid, and would happen even if the Mac multitasked 
  1266. preemptively. 
  1267.  
  1268. There IS "real" pre-emptive multitasking available for use in 
  1269. Mac applications; the expensive way is buying A/UX 3.0 which can 
  1270. have Mac applications written as UNIX processes; the cheap way 
  1271. is installing the Thread Manager which will allow you to create 
  1272. pre-emptive threads. However, the restrictions on those threads 
  1273. are the same as those on Time Manager tasks: don't call any 
  1274. function in an unloaded segment, and don't call QuickDraw or any 
  1275. toolbox call which may move memory (which are most ToolBox 
  1276. calls; paradoxally, BlockMove is safe :-) as are, surprisingly, 
  1277. FSRead and FSWrite) 
  1278.  
  1279. There are several problems with making the Mac OS preemptive; 
  1280. including apps that draw outside their windows or directly to 
  1281. screen, user dragging and other issues. 
  1282.  
  1283. 9.2) Q: What about protected memory? I'm sick and tired of 
  1284. re-booting when my application crashes. 
  1285.  
  1286. A: Write better software! 
  1287.  
  1288. Or install The Debugger from Jasik Designs, which can provide 
  1289. your application with write-protection of critical parts of 
  1290. memory. This may only work for 030 Macs, though. 
  1291.  
  1292. Making the Mac OS memory-protected is tricky, because 
  1293. applications expect to be able to write to low memory, the 
  1294. system heap, temporary memory, window lists, and even each 
  1295. other's heaps in some interapplication communication solutions 
  1296. that date back to before AppleEvents and the PPC Toolbox. 
  1297.  
  1298. *10* Handles; they are driving me crazy 
  1299.  
  1300. 10.1) Q: What is a handle? 
  1301.  
  1302. A: A handle is a pointer to a pointer to something. However, it 
  1303. is more than that; creating a handle by taking the address of 
  1304. one of your own pointers does NOT create a Handle; the Memory 
  1305. Manager will only deal properly with Handles that are created 
  1306. using NewHandle or something that calls it (such as NewRgn or 
  1307. GetResource) 
  1308.  
  1309. 10.2) Q: When do I have to lock a Handle? 
  1310.  
  1311. A: The contents of a Handle may move, and when it does, the 
  1312. pointer your handle is pointing to is changed to point to the 
  1313. new address so your handle is always valid. The toolbox may call 
  1314. the memory manager to allocate more memory pretty much anytime 
  1315.  
  1316. you call it (the toolbox) and when memory is allocated, your 
  1317. handle may move in memory. Don't dereference a handle into a 
  1318. pointer (or take the address of a field in a record a handle is 
  1319. double-pointing to) and then call the toolbox and expect the 
  1320. pointer to still be valid. The only way to ensure that the 
  1321. pointer will still be valid is to call HLock on the handle to 
  1322. lock it. 
  1323.  
  1324. Use HGetState and HSetState to save & restore the "locked" state 
  1325. of a handle when you lock it. 
  1326.  
  1327. 10.3) Q: How do I dispose of Handles? 
  1328.  
  1329. A: DisposeHandle (formerly called DisposHandle) once and ONLY 
  1330. once will do the trick. Trying to dispose of an already disposed 
  1331. Handle is an error. DoubleTrouble (see above) will catch such 
  1332. bugs when they do occur. 
  1333.  
  1334. 10.4) Q: What about resources? 
  1335.  
  1336. A: Calling GetResource returns NULL if the resource is not found 
  1337. or there is not enough memory, else it returns a handle to the 
  1338. resource. This handle may be moved or locked like any other 
  1339. handle, but DO NOT call DisposeHandle to get rid of a resource 
  1340. handle - call ReleaseResource. DisposeResource (see above) will 
  1341. catch this kind of bug. 
  1342.  
  1343. Remember that AddResource makes a resource handle out of an 
  1344. ordinary handle, and RmveResource or DetachResource makes an 
  1345. ordinary handle out of a resource handle. You cannot call 
  1346. AddResource with a resource handle; you have to DetachResource 
  1347. it first. 
  1348.  
  1349. Resource handles are automagically disposed when the resource 
  1350. file they belong to is closed. 
  1351.  
  1352. 10.5) Q: I'm trying to use a largish array in Think C, but get a 
  1353. "code overflow" error. This is valid C, why doesn't it work? 
  1354.  
  1355. A: The ANSI standard does not guarantee that any structure 
  1356. larger than 32767 bytes be correctly handled. Because of 
  1357. historical constraints, the Mac memory model is built around 
  1358. several small blocks of size 32K or less; these are used both 
  1359. for code and global/static data. If you want to use more code or 
  1360. data, you have to turn on "far code" or "far data" - you still 
  1361. will not get around the restriction of 32K code or data per 
  1362. compiled file, though. 
  1363.  
  1364. As opposed to, say, DOS or Windows, however, you can allocate as 
  1365. much memory as you want (and there is in the machine) and step 
  1366. through it using ordinary pointers; it's just that global and 
  1367. static data space is addressed off the A5 register using a 16bit 
  1368. displacement addressing mode in the 68000 processor. 
  1369.  
  1370. *11* _Gestalt and compatibility 
  1371.  
  1372. 11.1) Q: I see all these people call Gestalt without first 
  1373. checking whether it's implemented. Isn't that bad? 
  1374.  
  1375. A: No; Gestalt and a few other traps (the HXxx file manager 
  1376. traps, and FindFolder) are implemented using glue so they do the 
  1377. right thing even if the trap is not implemented. 
  1378.  
  1379. If you want to get rid of the glue, you can #define 
  1380. SystemSevenOrLater (and, using Think C/C++, re-pre-compile 
  1381. MacHeaders) However, then you will be responsible for checking 
  1382. for these features before you use them. 
  1383.  
  1384. 11.2) Q: What more functions are implemented in glue? 
  1385.  
  1386. A: Wake Up and Smell the Glue! [by Matthias Neeracher] 
  1387.  
  1388. How often have you wished you could use that cool new ToolBox 
  1389. call, but didn't want to make your application System 7 
  1390. dependent? Well, it might be that you *could* in fact have used 
  1391. the call. Several traps are implemented in glue, that is, much 
  1392. of their functionality is linked into your application and thus 
  1393. available even if you are running under an old System. 
  1394.  
  1395. This list applies to MPW 3.2 and should also be valid for the 
  1396. current version of Think C. If you find any inaccuracies, please 
  1397. report them to me. (neeri@iis.ee.ethz.ch) 
  1398.  
  1399. FSOpen: Tries first OpenDF, then Open. 
  1400.  
  1401. HOpenResFile: Full functionality emulated if trap not available 
  1402.  
  1403. HCreateResFile: Full functionality emulated if trap not 
  1404. available 
  1405.  
  1406. FindFolder: Under System 6, understands the following values for 
  1407. folderType and returns the System Folder for all of them: 
  1408.  
  1409. kAppleMenuFolderType 
  1410.  
  1411. kControlPanelFolderType 
  1412.  
  1413. kExtensionFolderType 
  1414.  
  1415. kPreferencesFolderType 
  1416.  
  1417. kPrintMonitorDocsFolderType 
  1418.  
  1419. kStartupFolderType 
  1420.  
  1421. kSystemFolderType 
  1422.  
  1423. kTemporaryFolderType 
  1424.  
  1425. SysEnvirons: Full functionality emulated if trap not available 
  1426.  
  1427. NewGestalt: Returns an error if not implemented 
  1428.  
  1429. ReplaceGestalt: Returns an error if not implemented 
  1430.  
  1431. Gestalt: The following selectors are always implemented: 
  1432.  
  1433. vers    mach    sysv    proc    fpu     
  1434.  
  1435. qd      kbd     atlk    ram     lram    
  1436.  
  1437. 11.3) Q: I have to support System 6, don't I? 
  1438.  
  1439. A: It would be foolish to lock yourself out of the many benefits 
  1440. the System 7 API provides for software that you start to write 
  1441. now. Some of the System 6 and older things (likely SFGetFile and 
  1442. wdRefNums among others) will be phased out of the interfaces and 
  1443. lose support; especially on future platforms. 
  1444.  
  1445. The installed base of System 7 is larger than that of System 6; 
  1446. this is not surprising because Apple has been shipping System 7 
  1447. for several years with all new machines, including the LCII, 
  1448. Classic II, Performas and Color Classic. Another argument is 
  1449. that newer computer owners (having System 7) are much more 
  1450. likely to buy new software than old computer owners who have 
  1451. systems that already do what they want them to. 
  1452.  
  1453. The added work to support both System 6 and System 7 is 
  1454. significant; if you have the time and money you may want to do 
  1455. it, but only supporting System 6 and not System 7 is doomed to 
  1456. fail in the market of today. 
  1457.  
  1458. Some may call this position subjective; I call it business sense 
  1459. based on market demographics. A rule of thumb may be that if you 
  1460. target color machines only, you can just as well demand System 7 
  1461. as well. 
  1462.  
  1463. *12* Standalone code and dynamic linking 
  1464.  
  1465. 12.1) Q: I've got a CODE resource off in limboland (sometimes 
  1466. called the resource fork) and I want to open it... what do I do? 
  1467. A: You open the file you have the code resource in, load the 
  1468. resource and lock it high (don't unlock it first, since someone 
  1469. else may be using it). Then you cast the handle to a function 
  1470. pointer, and call it normally. 
  1471.  
  1472. Suppose your code resource is compiled as a SACD id 128, and is 
  1473. defined as: 
  1474.  
  1475. *code*
  1476. long
  1477. main ( MyParams * params ) {
  1478.     switch ( params -> message ) {
  1479.     case messageInit :
  1480.         return init ( params ) ;
  1481.     ...
  1482.     }
  1483.     return 0L ;
  1484. }
  1485. *end*
  1486.  
  1487. Also suppose you already have the vRefNum, parID and name of the 
  1488. resource file you want to use. Do this: 
  1489.  
  1490. *code*
  1491.     setup_paramblock ( & the_params ) ;
  1492.     the_params . message = messageInit ;
  1493.     refNum = HOpenResFile ( vRefNum , parID , name , fsRdPerm ) ;
  1494.     if ( refNum < 1 ) {
  1495.         fail ( ResError ( ) ) ;
  1496.     }
  1497.     the_code = GetResource ( 'SACD' , 128 ) ;
  1498.     HLockHi ( the_code ) ;
  1499.     retval = ( * ( ( long ( * ) ( MyParams * ) ) StripAddress ( * the_code ) ) ) ( & the_params ) ;
  1500.     ...
  1501. *end*
  1502.  
  1503. The StripAddress is important; if your app is running in 24bit 
  1504. mode, the resource handle may contain tag bits and you don't 
  1505. want strange things to happen if the code resource switches into 
  1506. 32bit mode (which QuickDraw may do, incidentally)
  1507.  
  1508. Exactly how you structure your calling conventions is up to you; 
  1509. there is no accepted standard (except for HyperCard XCMDs, but 
  1510. that is probably overkill for you). 
  1511.  
  1512. *13* 
  1513.  
  1514. 13.1) Q: How do I read the modifier keys of the keyboard? 
  1515.  
  1516. A: Just call EventAvail and check the event.modifiers field. 
  1517. Only works when you are in the foreground. You can also use 
  1518. GetKeys(), or (as a last resort) check the lo-mem global KeyMap 
  1519. directly. 
  1520.  
  1521. 13.2) Q: How do I move the mouse cursor to a specific position?
  1522.  
  1523. A: Wait! Don't do it! There has to be a better way!
  1524.  
  1525. If you feel you HAVE to do it (for a game or VERY special
  1526. simulation situation) you can use the Cursor Device Manager
  1527. documented in the tech notes on ftp.apple.com. If that
  1528. manager is not installed, as it's not on older Macs, you can
  1529. use the following code:
  1530.  
  1531. ----- How to move the mouse (info in C): -----
  1532. you need to have some low-memory globals defined. they may be defined in
  1533. SysEqu.h.
  1534.  
  1535. #define MTemp 0x828
  1536. #define RawMouse 0x82c
  1537. #define CrsrNewCouple 0x8ce
  1538.  
  1539. note that CrsrNewCouple is actually a combination of two globals, just
  1540. to make our life slightly easier.
  1541.  
  1542. the code i use to move the mouse is:
  1543.  
  1544. *code*
  1545. void
  1546. MoveMouseTo ( Point where ) {
  1547.  
  1548.     HideCursor ( ) ;
  1549.     * ( Point * ) RawMouse = where ;
  1550.     * ( Point * ) MTemp = where ;
  1551.     * ( short * ) CrsrNewCouple = -1 ;
  1552.     ShowCursor ( ) ;
  1553. }
  1554. *end*
  1555.  
  1556. you need to hit a couple more global variables if you want this to
  1557. work properly in a multiple-monitor system, but i forget what they are 
  1558. offhand. poke through SysEqu.h, and you should be able to figure it out
  1559. without a problem.
  1560. ----------------------------------------------
  1561.  
  1562. On the PowerPC, these lo-mem globals may not be available for
  1563. native applications; however, all Power Macintoshes implement the
  1564. Cursor Device Manager.
  1565.  
  1566. There is also a file on nada.kth.se:pub/hacks/mac-faq/MoveMouse.c
  1567. which shows how to use the Cursor Device Manager, written by an
  1568. excellent Apple engineer. Grab!
  1569.  
  1570.  
  1571. *14* QuickTime 
  1572.  
  1573. 14.1) Q: I want to write a Amiga QuickTime player and need the 
  1574. CODEC format details. 
  1575.  
  1576. A: Although the structure of QuickTime movies is well documented 
  1577. in Inside Mac: QuickTime, the inner workings of the Apple 
  1578. compression modules is a trade secret that Apple will only 
  1579. license to you at great cost. Perhaps it's time for a freeware, 
  1580. cross-platform QuickTime codec? 
  1581.  
  1582. *15* Windows, Menus and Dialogs
  1583.  
  1584. 15.1) Q: My menus don't show up in the menu bar
  1585.  
  1586. A: If your menus are hiearchical, you'll have to install them
  1587. manually; GetNewMBar won't do it for you. See also 15.2.
  1588.  
  1589. 15.2) Q: When the user selects my menus, I get strange results
  1590. back; they seem to have different menu IDs than my menus?
  1591.  
  1592. A: The Menu ID as used by the menu manager is NOT the same
  1593. thing as the MENU resource ID (used in the MBAR resource and
  1594. with GetMenu()) When you create a MENU, ResEdit sets the menu
  1595. ID to the MENU resource ID, but if you re-number the resource,
  1596. you will have to open the menu in ResEdit and change the menu
  1597. ID usiung the "Edit MENU ID" menu item.
  1598.  
  1599. 15.3) Q: I use GetMenu() to find a menu in the menu bar, and then
  1600. change it, but it seems I have a memory leak OR my changes
  1601. don't "punch through"
  1602.  
  1603. A: GetMenu() is only intended if you don't already have the
  1604. menu "in memory." The call you should use almost all the time
  1605. is GetMHandle() which gets the handle to a menu in the current
  1606. menu bar by its menu ID (not resource id)
  1607.  
  1608. *16* Ice Cream and Frozen Yoghurt 
  1609.  
  1610. 16.1) Q: Dessert? 
  1611.  
  1612. A: Honey Hill Farms Cookie Jar Frozen Yoghurt or Haagen-Dazs 
  1613. Raspberry & Cream Ice Cream.
  1614.  
  1615. Hokey-Pokey icecream with chocolate sauce and (for those who 
  1616. like their brain food firmer) Almond and Double Chocolate 
  1617. CookieTime cookies!? [Denis Birnie]
  1618. -- 
  1619.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  1620.    This signature is kept shorter than 4 lines in the interests of UseNet
  1621.    S/N ratio.
  1622.